const http = require('http');
http.createServer(function(req, res) {
    console.log(req.url);
    const data = req.url.includes('?') ? req.url.split('?')[1]: null;
    //后端设置允许跨域
    res.setHeader("Access-Control-Allow-Origin","*");
    //设置响应的头信息
    res.writeHead(200,{"Content-type" : "text/plain;charset=utf-8"});
    if(data) {
        // a=b&c=d
        res.write(data.split('&')[0].split('=')[1]);
        res.end();
    } else {
        res.write('Hello');
        res.end();
    }
}).listen(8080);